Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Hit Identification

Once you have created a pick object and specified the model within a picking loop, QuickDraw 3D determines which, if any, of the objects in the model are suitably close to the pick geometry specified in the pick object. QuickDraw 3D uses hit-tests that are appropriate to the specific pick object and the objects in the model being tested. For example, if you're using a window-point pick object and your model contains a triangle, QuickDraw 3D tests whether the pick geometry--a point--is inside the two-dimensional screen projection of the triangle. If it is, QuickDraw 3D adds the triangle to the hit list.

For the window point pick geometry, QuickDraw 3D allows you to specify two tolerance values, which indicate how close a pick geometry must be to an object in a model for a hit to occur. A pick object's vertex tolerance indicates how close two points must be for a hit to occur. A pick object's edge tolerance indicates how close a point must be to a line for a hit to occur. Edge and vertex tolerances apply to mesh shape parts; edge tolerances apply to lines and polylines; and point tolerances apply to vertices.

Table 1 lists the hit-tests that QuickDraw 3D uses for window-space pick objects. The tolerances for these picks are floating-point values that specify units in the window coordinate system. QuickDraw 3D adds an object in a view to the hit list if the specified condition is fulfilled.

Table 1 Hit-tests for window-space pick objects 

Object

Point pick objects

Rectangle pick objects

Marker

The pick point is inside the marker bitmap and on an active pixel. (No tolerance is used.)

The pick rectangle intersects the marker bitmap and covers an active pixel in the bitmap.

Point

The distance from the pick point to the screen projection of the point is less than or equal to the vertex tolerance.

The screen projection of the point is within the pick rectangle.

Line

The distance from the pick point to the closest point on the screen projection of the line is less than or equal to the edge tolerance.

The screen projection of the line intersects the pick rectangle.

Triangle

The pick point is inside of the screen projection of the triangle.

The screen projection of the triangle intersects the pick rectangle or lies completely within it.

Polygon

The pick point is inside of the screen projection of the polygon.

The screen projection of the polygon intersects the pick rectangle or lies completely within it.

Mesh

For object picking, the pick point is inside of the screen projection of any element of the mesh. For mesh vertex, edge, or face picking, the criteria for points, line, and triangles apply, respectively.

For object picking, the screen projection of any element of the mesh intersects the pick rectangle or lies completely within it. For mesh vertex, edge, or face picking, the criteria for points, line, and triangles apply, respectively

If the view within which picking is occurring is associated with a pixmap draw context, you need to transform the window-space pick coordinates (usually obtained from the mouse coordinates) to the pixmap's coordinate space. You can use original QuickDraw's MapPt function to do this.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |